
#include <OIS.h>
#include "MenuWindow.h"
#include "DebugBar.h"
#include "Console.h"
#include "HintWindow.h"

class OgreApplication;

class MenuHandler : public OIS::MouseListener, OIS::KeyListener{

	static OgreApplication* ogre_app;

	 
	
	void initNull();
	
	// controls
	
	bool	captureControls;
	bool	captureMouse;
	bool	captureKeyboard;

	bool	isCapturingControls();
	void	setCapturingControls(bool state = true,bool mouse = false,bool keyboard = false);

	void	setCaptures();
	void	removeCaptures();

	bool	isCapturingMouse();
	bool	isCapturingKeyboard();


	//vector stuff

	std::vector<MenuWindow*>* windows;

	void initWindowVector();
	void destroyWindowVector();

	MenuWindow* getWindow(int index);
	MenuWindow* getWindow(Ogre::String name);

	void		addWindow(Ogre::String name);
	int			getIndex(Ogre::String name);
	bool		doesExist(Ogre::String name);

	bool		isAnyWindowShown();

	// hint/console/debugbar
	
	DebugBar*	debug_bar;		
	Console*	console;
	HintWindow*	hint_wind;

public:

	void showDebugBar();
	void closeDebugBar();

	void showConsole();
	void closeConsole();

	void hint(Ogre::String text);

private:

	//cegui stuff
	
	CEGUI::OgreRenderer* gCEGUIOgreRenderer;

	void initCEGUI();
	void destroyCEGUI();



	CEGUI::MouseButton convertButton(OIS::MouseButtonID btn);

	// OIS::KeyListener
    virtual bool keyPressed( const OIS::KeyEvent &arg );
    virtual bool keyReleased( const OIS::KeyEvent &arg );
    // OIS::MouseListener
    virtual bool mouseMoved( const OIS::MouseEvent &arg );
    virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
    virtual bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );

	public:

	MenuHandler(OgreApplication* ogre_app);
	~MenuHandler();

	
	void update(unsigned long millis);



};